import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(vuex)

const store = new Vuex.Store({
	state: {
		hashLogin: false,
		userInfo: {}
	},
	mutations: {
		login(state, userinfo) {
			state.hasLogin = true;
			state.userInfo = userinfo;
			uni.setStorage({//缓存用户登陆状态
			    key: 'userInfo',
			    data: userinfo
			})
		},
		logout() {
			state.hasLogin = false;
			state.userInfo = {};
			uni.removeStorage({  
			    key: 'userInfo'  
			})
		}
	}
	actions: {}
})

export default store